#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 20, M = 1 << N, INF = 0x3f;
int a[N][N], n;
int dp[M][N];

int main()
{
    memset(dp, 0x3f, sizeof dp);
    cin >> n;
    dp[1][0] = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            cin >> a[i][j];
    for(int i = 0; i < 1 << n; ++i)
        for(int j = 0; j < n; ++j)
            if((i >> j) & 1)   // 如果说当前状态包含这个城市，进行规划
            {
                int pre = i - (1 << j);
                for(int k = 0; k < n; ++k)
                    if((pre >> k) & 1)
                        dp[i][j] = min(dp[pre][k] + a[k][j], dp[i][j]);
            }
    int res = 0x3f3f3f3f;
    for(int i = 2; i < n; ++i)
        res = min(res, dp[(1 << n) - 1][i] + a[i][0]);
    cout << res << endl;
    return 0;
}